package com.project.entity.sys;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import org.hibernate.criterion.Order;

@MappedSuperclass
public abstract class BaseEntity implements Serializable{
	
	private static final long serialVersionUID = 1L;

	@Transient
	private Integer pageNo = 1;
	@Transient
	private Integer pageSize = 10;
	
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true ,nullable = false)
	private Long id;
	
	@Transient
	private Order cOrder;
	
	@Transient
	private List<Order> rank;//多字段排序
	
	/**删除标志：0有效   1删除*/
    @Column
    private Integer dr;

	public Integer getPageNo() {
		return pageNo;
	}

	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Order getcOrder() {
		return cOrder;
	}

	public void setcOrder(Order cOrder) {
		this.cOrder = cOrder;
	}
	
	public List<Order> getRank() {
		return rank;
	}

	public void setRank(List<Order> rank) {
		this.rank = rank;
	}

	public Object deepCopy() throws Exception  
    {  
        // 将该对象序列化成流,因为写在流里的是对象的一个拷贝，而原对象仍然存在于JVM里面。所以利用这个特性可以实现对象的深拷贝  
        ByteArrayOutputStream bos = new ByteArrayOutputStream();  
  
        ObjectOutputStream oos = new ObjectOutputStream(bos);  
  
        oos.writeObject(this);  
  
        // 将流序列化成对象  
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());  
  
        ObjectInputStream ois = new ObjectInputStream(bis);  
  
        return ois.readObject();  
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

    public Integer getDr() {
        return dr;
    }

    public void setDr(Integer dr) {
        this.dr = dr;
    }
}
